let mix = require('laravel-mix')
let webpack = require('webpack')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
var uglify = null
if (process.env.build === 'build') {
    uglify = new UglifyJsPlugin({
        uglifyOptions: {
          compress: {
            warnings: false,
            drop_debugger: true,
            drop_console: true
          }
        }
      })
} else {
    uglify = new UglifyJsPlugin({
        uglifyOptions: {
          compress: {
            warnings: false
          }
        }
      })
}
let env = require('./env.'+process.env.build+'.js')
const { cssProduce,javascriptProduce } = require('./webpackRouter')
let envConfig = new webpack.DefinePlugin({
    'process.env': env
  })
mix.webpackConfig({
    module: {
        rules: [
            {
                test: /\.(eot|svg|ttf|woff|woff2)\w*/,
                loader: 'url-loader',
                options: {
                    limit: 10000,
                    name: 'dist/fonts/[name].[hash:7].[ext]',
                    publicPath: 'dist/fonts/'
                }   
            }
        ]
    },
    plugins: [
        envConfig,
        uglify
    ]
});
javascriptProduce(mix); // 打包js
